import { defineStore } from 'pinia'
import { reqGetVerifyCode, reqRegisterUser, reqUserLogin, reqUserLogout } from '../api/login'

const useLogin = defineStore('login', {
  state: () => {
    return {
      name:localStorage.getItem('name'),
      token :localStorage.getItem('token'),
    }
  },
  actions: {
    // 登录
    async getReqUserLogin(user) {
      const result = await reqUserLogin(user)
      localStorage.setItem('name', result.name)
      localStorage.setItem('token', result.token)
      this.token = result.token
      return 'ok'
    },
  },
  getters: {
  }
})

export default useLogin